<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>详情页</title>
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        header a{
            text-decoration: none;
            color: #6c6c6c;
        }
    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-header height="150px">
            <div style="width: 1200px; margin: 0 auto; background-color: #3f3f3f " >
                <img src="sc.png" style="width:300px; height: 102px; vertical-align:middle" alt="">
                <a href="">商品展示</a><el-divider direction="vertical"></el-divider>
                <a href="">站内搜索</a><el-divider direction="vertical"></el-divider>
                <a href="">个人中心</a><el-divider direction="vertical"></el-divider>
                <a href="">购物车</a><el-divider direction="vertical"></el-divider>
                <a href="">下单</a><el-divider direction="vertical"></el-divider>
                <a href="">网站公告</a><el-divider direction="vertical"></el-divider>
            </div>
            <!--导航菜单开始-->
            <div style="background-color: azure ">
                <el-menu style="width: 1200px;margin: 0 auto"
                         :default-active="activeIndex"
                         class="el-menu-demo"
                         mode="horizontal"
                         @select="handleSelect"
                         background-color="#82c8ec"
                         text-color="#fff"
                         active-text-color="#fff">
                    <el-menu-item v-for="c in categoryArr" :index="c.id">{{c.name}}</el-menu-item>

                    <div style="float: right;position: relative;top: 10px">
                        <el-input placeholder="请输入搜索内容" v-model="wd">
                            <el-button slot="append" icon="el-icon-search" @click="search()"></el-button>
                        </el-input>
                    </div>
                </el-menu>
            </div>
            <!--导航菜单结束-->
        </el-header>
        <el-main style="width: 1200px;margin: 0 auto">
            <el-row gutter="20">
                <el-col span="12">
                    <el-card>
                        <img :src="p.url" width="100%" alt="">
                    </el-card>
                </el-col>
                <el-col span="12">
                    <p style="font-size: 25px">{{p.title}}</p>
                    <span style="color: #666;font-size: 12px">
                        发布于:{{p.created}}</span>
                    <el-divider></el-divider>
                    <p style="font-size: 15px;color: #666">
                        销量:{{p.saleCount}} 浏览量:{{p.viewCount}}</p>
                    <p style="font-size: 25px;font-weight: bold">
                        ￥{{p.price}}
                        <span style="font-size: 15px;color: #666">原价:<s>{{p.oldPrice}}</s></span>
                    </p>
                    <el-row gutter="20" style="text-align: center">
                        <el-col span="8">
                            <el-card>
                                <img src="" width="100%" alt="">
                            </el-card>
                            <p>扫描购买商品</p>
                        </el-col>
                        <el-col span="8">
                            <el-card>
                                <img src="" width="100%" alt="">
                            </el-card>
                            <p>扫描下载App</p>
                        </el-col>
                    </el-row>
                </el-col>
            </el-row>
        </el-main>
        <el-footer>
            <div style="height: 60px;background-color: blanchedalmond">
            </div>
            <div style="background-color: #82c8ec;padding:25px 0;text-align: center;">
                <a href="">关于我们</a><el-divider direction="vertical"></el-divider>
                <a href="">招聘信息</a><el-divider direction="vertical"></el-divider>
                <a href="">招商合作</a><el-divider direction="vertical"></el-divider>
                <a href="">帮助页面</a><el-divider direction="vertical"></el-divider>
                <p>云尚臻城,大品牌海量商品为生活助力,至臻至诚为您服务.</p>
            </div>
        </el-footer>
    </el-container>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
                activeIndex:"",
                wd:"",
                categoryArr:[],
                p:{}
            }
        },
        methods: {
            handleSelect(key,keyPath){
                console.log(key,keyPath);
                location.href="/result.html?id="+key;
            },
            search(){
                location.href="/result.html?id="+v.wd;
            }
        },
        created:function () {
            axios.get("/category/select").then(function (response) {
                v.categoryArr = response.data;
            })
            //发请求通过id获取商品详情
            axios.get("/product/selectById/detail"+location.search)
                .then(function (response) {
                    v.p = response.data;
                })
        }
    })
</script>
</html>